#include <iostream>

#include "factory.h"

using namespace std;

int main()
{
    double x = 0;
    double y = 0;
    string operate;
    cout << "Please input first number:" << endl;
    cin >> x;
    cout << "Please input operator(+, -, *, /):" << endl;
    cin >> operate;
    cout << "Please input second number:" << endl;
    cin >> y;

    IFactory *factory = nullptr;
    switch(operate[0]) {
        case '+':
            factory = new AddFactory();
            break;
        case '-':
            factory = new SubFactory();
            break;
        case '*':
            factory = new MulFactory();
            break;
        case '/':
            factory = new DivFactory();
            break;
        default:
            std::cout << "Invalid operator. Please input +, -, * or /." << std::endl;
            exit(-1);
    }
    Operation *op = factory->CreateOperation();
    cout << "Output: " << op->GetResult(x, y) << endl;
    return 0;
}